package main

import "fmt"

func SearchBool() (boolQuery map[string]any, query map[string]any) {
	boolQuery = map[string]any{
		"must":     []any{},
		"must_not": []any{},
		"filter":   []any{},
		"should":   []any{},
	}

	query = map[string]any{
		"query": map[string]any{
			"bool": boolQuery,
		},
		"sort": []any{
			map[string]any{
				"_score": map[string]any{
					"order": "desc",
				},
				"id": map[string]any{
					"order": "asc", // desc 降序
				},
			},
		},
		"from": 0,
		"size": 10,
	}
	return
}

func main() {
	boolQuery, query := SearchBool()
	termQuery := map[string]any{
		"term": map[string]any{
			"is_hot": 1,
		},
	}
	boolQuery["filter"] = append(boolQuery["filter"].([]any), termQuery)
	fmt.Println(boolQuery)
	fmt.Println(query["query"].(map[string]any)["bool"])
}
